package com.chinackts.customsdeclarations.controller;

import com.alibaba.fastjson.JSONObject;
import com.chinackts.customsdeclarations.dto.CustomsDeclarationsListDto;
import com.chinackts.customsdeclarations.query.CustomsDeclarationsDetailsQuery;
import com.chinackts.customsdeclarations.query.CustomsDeclarationsListQuery;
import com.chinackts.customsdeclarations.query.CustomsDeclarationsPageListQuery;
import com.chinackts.customsdeclarations.service.CustomsDeclarationsService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Lianhong
 * @since 2021/11/18
 */
@RestController
public class CustomsDeclarationsController implements CustomsDeclarationsControllerInterface {

    @Resource
    private CustomsDeclarationsService customsDeclarationsService;

    @Override
    public ResponseEntity<CustomsDeclarationsListDto> list(String id, CustomsDeclarationsListQuery query) {
        return ResponseEntity.ok(customsDeclarationsService.list(id, query));
    }

    @Override
    public ResponseEntity<CustomsDeclarationsListDto> pageList(String id, CustomsDeclarationsPageListQuery query) {
        return ResponseEntity.ok(customsDeclarationsService.pageList(id, query));
    }

    @Override
    public ResponseEntity<JSONObject> details(String id, String entryId, CustomsDeclarationsDetailsQuery query) {
        return ResponseEntity.ok(customsDeclarationsService.details(id, entryId, query));
    }

    @Override
    public ResponseEntity<JSONObject> customsDeclarationDetails(String id, String entryId, CustomsDeclarationsDetailsQuery query) {
        return ResponseEntity.ok(customsDeclarationsService.details(id, entryId, query));
    }

    @Override
    public ResponseEntity<Void> customsDeclarationsPdf(String id, String entryId, HttpServletResponse response) {
        customsDeclarationsService.customsDeclarationsPdf(id, entryId, response);
        return ResponseEntity.noContent().build();
    }
}
